using System;
using System.Collections.Generic;
using System.Text;
using System.Transactions;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;
using OracleInternal.I18N;
using OracleInternal.Network;
using OracleInternal.ServiceObjects;
using OracleInternal.TTC.Accessors;

namespace OracleInternal.TTC
{
	internal class TTCExecuteSql : TTCFunction
	{
		internal struct MarshalBindParameterValueHelper
		{
			internal object[] m_paramValueArray;

			internal object[] m_qLocatorDataArray;

			internal ColumnDescribeInfo[] m_paramCollInfoArray;

			internal BindDirection[] m_bindDirections;

			internal bool m_bAllInBinds;

			internal bool m_bAllOutBinds;

			internal bool m_IsInArrayBindingMode;

			internal bool m_InTTISLGMode;

			internal bool m_bWriteOutParamVal;

			internal List<int> m_indexOfLongParamsWithLargeData;

			internal List<int> m_bindIndexOfLongParamsWithLargeData;

			internal SqlStatementType m_sqlStmtType;

			internal static readonly MarshalBindParameterValueHelper Null;

			internal bool m_offsetRowIndicesForwardByOne;

			internal void EvaluateBindDirections()
			{
				bool flag = false;
				bool flag2 = false;
				if (m_bindDirections == null)
				{
					return;
				}
				for (int i = 0; i < m_bindDirections.Length; i++)
				{
					if (m_bindDirections[i] == BindDirection.InputOutput)
					{
						flag = true;
						flag2 = true;
					}
					else if (m_bindDirections[i] == BindDirection.Input)
					{
						flag = true;
					}
					else if (m_bindDirections[i] == BindDirection.Output)
					{
						flag2 = true;
					}
					if (flag && flag2)
					{
						m_bAllInBinds = false;
						m_bAllOutBinds = false;
						return;
					}
				}
				if (flag && !flag2)
				{
					m_bAllInBinds = true;
					m_bAllOutBinds = false;
				}
				else if (flag2 && !flag)
				{
					m_bAllOutBinds = true;
					m_bAllInBinds = false;
				}
			}

			internal bool Equals(MarshalBindParameterValueHelper obj)
			{
				if (m_paramValueArray != obj.m_paramValueArray && m_paramCollInfoArray != obj.m_paramCollInfoArray)
				{
					return m_bindDirections == obj.m_bindDirections;
				}
				return true;
			}

			internal void MarshalBindParameters(MarshallingEngine mEngine, int rowIndexToSendFrom, int numberOfSubsequentRowsToSend)
			{
				if (m_IsInArrayBindingMode)
				{
					MarshalArrayBindValues(mEngine, rowIndexToSendFrom, numberOfSubsequentRowsToSend);
				}
				else
				{
					MarshalBindValues(mEngine);
				}
			}

			internal void ResetBindDirections(int origParamCount)
			{
				if (m_bindDirections == null)
				{
					m_bindDirections = new BindDirection[origParamCount];
					for (int i = 0; i < m_bindDirections.Length; i++)
					{
						m_bindDirections[i] = BindDirection.Input;
					}
				}
			}

			internal void MarshalBindValues(MarshallingEngine mEngine)
			{
				if (m_InTTISLGMode)
				{
					mEngine.MarshalUB1(7);
					if (m_indexOfLongParamsWithLargeData == null || m_bindIndexOfLongParamsWithLargeData == null)
					{
						return;
					}
					int num = 0;
					for (int i = 0; i < m_indexOfLongParamsWithLargeData.Count; i++)
					{
						if ((m_paramCollInfoArray[m_indexOfLongParamsWithLargeData[i]].m_flag | 0x80) != 128)
						{
							if (m_bindDirections == null || m_bindDirections[m_bindIndexOfLongParamsWithLargeData[num]] != BindDirection.Output)
							{
								MarshalParameterValue(mEngine, m_paramValueArray[m_indexOfLongParamsWithLargeData[i]], (byte[])m_qLocatorDataArray[i], (OraType)m_paramCollInfoArray[m_indexOfLongParamsWithLargeData[i]].m_dataType);
							}
							num++;
						}
					}
				}
				else
				{
					MarshalSingleRow(mEngine);
				}
			}

			private void MarshalSingleRow(MarshallingEngine mEngine)
			{
				mEngine.MarshalUB1(7);
				if (m_bindIndexOfLongParamsWithLargeData != null)
				{
					m_bindIndexOfLongParamsWithLargeData.Clear();
				}
				else
				{
					m_bindIndexOfLongParamsWithLargeData = new List<int>();
				}
				int num = 0;
				for (int i = 0; i < m_paramValueArray.Length; i++)
				{
					if ((m_paramCollInfoArray[i].m_flag | 0x80) == 128)
					{
						continue;
					}
					if (m_bWriteOutParamVal || m_bindDirections == null || m_bindDirections[num] != BindDirection.Output)
					{
						if (m_paramCollInfoArray[i].m_maxNoOfArrayElements > 0)
						{
							MarshalAssociativeArrayParameterValue(mEngine, m_paramValueArray[i], (OraType)m_paramCollInfoArray[i].m_dataType);
						}
						else if (!m_indexOfLongParamsWithLargeData.Contains(i))
						{
							MarshalParameterValue(mEngine, m_paramValueArray[i], (byte[])m_qLocatorDataArray[i], (OraType)m_paramCollInfoArray[i].m_dataType);
						}
						else
						{
							m_bindIndexOfLongParamsWithLargeData.Add(num);
						}
					}
					num++;
				}
				if (m_indexOfLongParamsWithLargeData == null || m_bindIndexOfLongParamsWithLargeData == null)
				{
					return;
				}
				num = 0;
				for (int j = 0; j < m_indexOfLongParamsWithLargeData.Count; j++)
				{
					if ((m_paramCollInfoArray[m_indexOfLongParamsWithLargeData[j]].m_flag | 0x80) != 128)
					{
						if (m_bindDirections == null || m_bindDirections[m_bindIndexOfLongParamsWithLargeData[num]] != BindDirection.Output)
						{
							MarshalParameterValue(mEngine, m_paramValueArray[m_indexOfLongParamsWithLargeData[j]], (byte[])m_qLocatorDataArray[j], (OraType)m_paramCollInfoArray[m_indexOfLongParamsWithLargeData[j]].m_dataType);
						}
						num++;
					}
				}
			}

			internal void MarshalArrayBindValues(MarshallingEngine mEngine, int rowIndexToSendFrom, int numberOfSubsequentRowsToSend)
			{
				if (m_offsetRowIndicesForwardByOne)
				{
					rowIndexToSendFrom++;
				}
				int num = numberOfSubsequentRowsToSend + rowIndexToSendFrom - 1;
				if (rowIndexToSendFrom > num)
				{
					return;
				}
				if (m_InTTISLGMode)
				{
					mEngine.MarshalUB1(7);
					if (m_indexOfLongParamsWithLargeData != null && m_bindIndexOfLongParamsWithLargeData != null)
					{
						int num2 = 0;
						for (int i = 0; i < m_indexOfLongParamsWithLargeData.Count; i++)
						{
							if ((m_paramCollInfoArray[m_indexOfLongParamsWithLargeData[i]].m_flag | 0x80) != 128)
							{
								if (m_bindDirections == null || m_bindDirections[m_bindIndexOfLongParamsWithLargeData[num2]] != BindDirection.Output)
								{
									MarshalParam(mEngine, rowIndexToSendFrom, m_indexOfLongParamsWithLargeData[i], m_bindIndexOfLongParamsWithLargeData[num2], isFirstRow: true);
								}
								num2++;
							}
						}
					}
					rowIndexToSendFrom++;
				}
				if (rowIndexToSendFrom <= num)
				{
					MarshalRows(mEngine, rowIndexToSendFrom, num);
				}
			}

			private void MarshalRows(MarshallingEngine mEngine, int rowIndexToSendFrom, int rowIndexToSendUntil)
			{
				for (int i = rowIndexToSendFrom; i <= rowIndexToSendUntil; i++)
				{
					mEngine.MarshalUB1(7);
					if (m_bindIndexOfLongParamsWithLargeData != null)
					{
						m_bindIndexOfLongParamsWithLargeData.Clear();
					}
					else
					{
						m_bindIndexOfLongParamsWithLargeData = new List<int>();
					}
					int num = 0;
					for (int j = 0; j < m_paramValueArray.Length; j++)
					{
						if ((m_paramCollInfoArray[j].m_flag | 0x80) == 128)
						{
							continue;
						}
						if (m_bindDirections == null || m_bindDirections[num] != BindDirection.Output)
						{
							if (!m_indexOfLongParamsWithLargeData.Contains(j))
							{
								MarshalParam(mEngine, i, j, num, rowIndexToSendFrom == i);
							}
							else
							{
								m_bindIndexOfLongParamsWithLargeData.Add(num);
							}
						}
						num++;
					}
					if (m_indexOfLongParamsWithLargeData == null || m_bindIndexOfLongParamsWithLargeData == null)
					{
						continue;
					}
					num = 0;
					for (int k = 0; k < m_indexOfLongParamsWithLargeData.Count; k++)
					{
						if ((m_paramCollInfoArray[m_indexOfLongParamsWithLargeData[k]].m_flag | 0x80) != 128)
						{
							if (m_bindDirections == null || m_bindDirections[m_bindIndexOfLongParamsWithLargeData[num]] != BindDirection.Output)
							{
								MarshalParam(mEngine, i, m_indexOfLongParamsWithLargeData[k], m_bindIndexOfLongParamsWithLargeData[num], rowIndexToSendFrom == i);
							}
							num++;
						}
					}
				}
			}

			private void MarshalParam(MarshallingEngine mEngine, int rowIndex, int paramIndex, int bindIndex, bool isFirstRow)
			{
				OraType dataType = (OraType)m_paramCollInfoArray[paramIndex].m_dataType;
				if (m_paramValueArray[paramIndex] != null && (m_bindDirections == null || m_bindDirections[bindIndex] != BindDirection.Output))
				{
					MarshalParameterValue(mEngine, ((byte[][])m_paramValueArray[paramIndex])[rowIndex], ((byte[][])m_qLocatorDataArray[paramIndex])[rowIndex], dataType);
				}
				else if (SqlStatementType.PLSQL != m_sqlStmtType || isFirstRow || m_bindDirections[bindIndex] != BindDirection.Output)
				{
					MarshalParameterValue(mEngine, null, (byte[])m_qLocatorDataArray[paramIndex], dataType);
				}
			}
		}

		private const int UOPF_PRS = 1;

		private const int UOPF_BND = 8;

		private const int UOPF_EXE = 32;

		private const int UOPF_FEX = 512;

		private const int UOPF_FCH = 64;

		private const int UOPF_CAN = 128;

		private const int UOPF_COM = 256;

		private const int UOPF_DSY = 8192;

		private const int UOPF_SIO = 1024;

		private const int UOPF_NPL = 32768;

		private const int UOPF_DFN = 16;

		private const int UOPF_NCF = 262144;

		private const int UOPF_BER = 524288;

		private const int UOPF_SCN = 2097152;

		private const int KPUCXDSY = 131072;

		internal const int AL8KW_CURRENCY = 0;

		internal const int AL8KW_ISOCURR = 1;

		internal const int AL8KW_NUMERICS = 2;

		internal const int AL8KW_DATEFM = 7;

		internal const int AL8KW_DATELANG = 8;

		internal const int AL8KW_TERRITORY = 9;

		internal const int AL8KW_CHARSET = 10;

		internal const int AL8KW_SORT = 11;

		internal const int AL8KW_CALENDAR = 12;

		internal const int AL8KW_LANGUAGE = 16;

		internal const int AL8KW_NLSCOMP = 50;

		internal const int AL8KW_UNIONCUR = 52;

		internal const int AL8KW_TIMEFM = 57;

		internal const int AL8KW_STMPFM = 58;

		internal const int AL8KW_TTZNFM = 59;

		internal const int AL8KW_STZNFM = 60;

		internal const int AL8KW_NLSLENSEM = 61;

		internal const int AL8KW_NCHAREXCP = 62;

		internal const int AL8KW_NCHARIMP = 63;

		internal const int AL8KW_MAXLANG = 63;

		internal const int AL8KW_TIMEZONE = 163;

		internal const int AL8KW_ERR_OVLAP = 164;

		internal const int AL8KW_SESSION_ID = 165;

		internal const int AL8KW_SERIAL_NUM = 166;

		internal const int AL8KW_TAG_FOUND = 167;

		internal const int AL8KW_SCHEMA_NAME = 168;

		internal const int AL8KW_SCHEMA_ID = 169;

		internal const int AL8KW_ENABLED_ROLES = 170;

		internal const int AL8KW_AUX_SESSSTATE = 171;

		internal const int AL8KW_EDITION = 172;

		internal const int AL8KW_SQL_TXLP = 173;

		internal const int AL8KW_FSQL_SNTX = 174;

		internal const int AL8KW_OPENCURSORS = 175;

		internal const int AL8KW_PDBUID = 176;

		internal const int AL8KW_DBID = 177;

		internal const int AL8KW_GUDBID = 178;

		internal const int AL8KW_DBNAME = 179;

		internal const int AL8KW_PDB_SDATE = 180;

		internal const int AL8KW_PDB_STIME = 181;

		internal const int AL8KW_MAX_IDEN_LENGTH = 182;

		internal const int AL8KW_SERVICE_NAME = 183;

		internal const int AL8KW_MODULE = 184;

		internal const int AL8KW_ACTION = 185;

		internal const int AL8KW_CLIENT_INFO = 186;

		internal const int AL8KW_ROW_ARCHIVAL = 187;

		internal const int AL8KW_FAILOVER_TYPE = 188;

		internal const int AL8KW_FAILOVER_DELAY = 189;

		internal const int AL8KW_FAILOVER_RETRIES = 190;

		internal const int AL8KW_FAILOVER_METHOD = 191;

		internal const int AL8KW_COMMIT_OUTCOME = 192;

		internal const int AL8KW_SERVICE_FLAGS = 193;

		internal const int AL8KW_SESSSTATE_CONS = 194;

		internal const int AL8KW_REPLAY_TIMEOUT = 195;

		internal const int AL8KW_FAILOVER_RESTORE = 196;

		internal const int AL8KW_CONTAINER_NAME = 197;

		internal const int AL8KW_CLIENT_ID = 198;

		internal const string AL8KW_NLSCOMP_M = "AL8KW_NLSCOMP";

		internal const int LONGLIMITFOR12G = 32767;

		internal const int LONGLIMITFORDBLESSTHAN12G = 4000;

		private const long AL8EX_GET_PIDMLRC = 16384L;

		private const long AL8EX_IMPL_RESULTS_CLIENT = 32768L;

		private long[] m_al8i4 = new long[13];

		private TTCRowHeader m_rowHeader;

		private TTCRowData m_rowData;

		private TTCReExecuteSql m_reExecuteSql;

		internal byte[] m_sessionTimeZone;

		internal bool m_bSessionTimeZoneUpdated;

		internal TTCReExecuteSql ReExecuteSqlObject
		{
			get
			{
				if (m_reExecuteSql == null)
				{
					m_reExecuteSql = new TTCReExecuteSql(m_marshallingEngine);
				}
				return m_reExecuteSql;
			}
		}

		internal TTCExecuteSql(MarshallingEngine mEngine)
			: base(mEngine, 94, 0)
		{
		}

		internal override void ReInit(MarshallingEngine marshallingEngine)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.ReInit);
			}
			try
			{
				base.ReInit(marshallingEngine);
				if (m_reExecuteSql != null)
				{
					m_reExecuteSql.ReInit(marshallingEngine);
				}
				m_al8i4 = new long[13];
				m_sessionTimeZone = null;
				m_bSessionTimeZoneUpdated = false;
				if (m_rowHeader != null)
				{
					m_rowHeader.ReInit(m_marshallingEngine);
				}
				if (m_rowData != null)
				{
					m_rowData.ReInit(m_marshallingEngine);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.ReInit, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.ReInit);
				}
			}
		}

		internal void SendReExecuteRequest(OracleConnectionImpl commImpl, int cursorId, long noOfRowsToFetch, bool bAutoCommit, bool bDisableCompressedFetch, SqlStatementType stmtType, int arrayBindCount, ref MarshalBindParameterValueHelper marshalArrayBindValuesHelper)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.SendReExecuteRequest);
			}
			short ttcCallCode = 4;
			int num = 0;
			int num2 = 0;
			long numIterations = 1L;
			bool bArrayBinding = false;
			try
			{
				if (stmtType == SqlStatementType.SELECT && noOfRowsToFetch > 0)
				{
					ttcCallCode = 78;
					num |= 0x20;
					if (bDisableCompressedFetch)
					{
						num |= 0x40000;
					}
					numIterations = noOfRowsToFetch;
					if (arrayBindCount > 0)
					{
						bArrayBinding = true;
						numIterations = arrayBindCount;
					}
				}
				else
				{
					if (arrayBindCount > 0)
					{
						bArrayBinding = true;
						numIterations = arrayBindCount;
					}
					if (bAutoCommit)
					{
						num2 |= 1;
					}
				}
				ValidateTransactionContext(commImpl);
				ReExecuteSqlObject.WriteMessage(ttcCallCode, cursorId, num, num2, numIterations, bArrayBinding, ref marshalArrayBindValuesHelper);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.SendReExecuteRequest, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.SendReExecuteRequest);
				}
			}
		}

		internal void SendExecuteRequest(OracleConnectionImpl commImpl, byte[] sqlStmtByteStream, bool bHasReturningClause, int cursorId, byte[] describeInfoHash, long dbChangeRegistrationId, ColumnDescribeInfo[] columnDefines, long noOfRowsToFetch, bool parse, bool execute, bool fetch, bool define, bool bAutoCommit, bool bDisableCompressedFetch, SqlStatementType stmtType, int longFetchSize, int arrayBindCount, long[] scnForSnapshot, ref MarshalBindParameterValueHelper marshalBindParamsHelper, int startIndex)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.SendExecuteRequest);
			}
			try
			{
				if (dbChangeRegistrationId > 0 && stmtType != 0 && SqlStatementType.PLSQL != stmtType)
				{
					throw new OracleException(29973, string.Empty, string.Empty, OracleStringResourceManager.GetErrorMesgWithErrCode(29973));
				}
				int noOfParameters = ((marshalBindParamsHelper.m_paramCollInfoArray != null) ? marshalBindParamsHelper.m_paramCollInfoArray.Length : 0);
				for (int i = 0; i < m_al8i4.Length; i++)
				{
					m_al8i4[i] = 0L;
				}
				long executeOptions = GetExecuteOptions(parse, execute, fetch, define, bAutoCommit, bDisableCompressedFetch, bHasReturningClause, noOfParameters, arrayBindCount, stmtType);
				if ((executeOptions & 1) > 0)
				{
					m_al8i4[0] = 1L;
				}
				else
				{
					m_al8i4[0] = 0L;
				}
				switch (stmtType)
				{
				case SqlStatementType.OTHERS:
					m_al8i4[1] = 1L;
					break;
				case SqlStatementType.DML:
				case SqlStatementType.PLSQL:
					if (arrayBindCount > 0)
					{
						m_al8i4[1] = arrayBindCount;
						if (stmtType == SqlStatementType.DML)
						{
							m_al8i4[9] = 16384L;
						}
					}
					else
					{
						m_al8i4[1] = 1L;
					}
					break;
				default:
					if (fetch)
					{
						m_al8i4[1] = noOfRowsToFetch;
					}
					else
					{
						m_al8i4[1] = 0L;
					}
					break;
				}
				if (scnForSnapshot != null)
				{
					m_al8i4[5] = scnForSnapshot[0];
					m_al8i4[6] = scnForSnapshot[1];
				}
				else
				{
					m_al8i4[5] = (m_al8i4[6] = 0L);
				}
				if (stmtType == SqlStatementType.SELECT)
				{
					m_al8i4[7] = 1L;
				}
				else
				{
					m_al8i4[7] = 0L;
				}
				if ((executeOptions & 0x20) != 0L)
				{
					m_al8i4[9] |= 32768L;
				}
				else
				{
					m_al8i4[9] &= -32769L;
				}
				int numDefineCols = 0;
				if (define && columnDefines != null)
				{
					numDefineCols = columnDefines.Length;
				}
				ValidateTransactionContext(commImpl);
				WriteOall8Message(sqlStmtByteStream, cursorId, describeInfoHash, dbChangeRegistrationId, executeOptions, columnDefines, longFetchSize, arrayBindCount, numDefineCols, noOfRowsToFetch, stmtType, ref marshalBindParamsHelper, startIndex);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.SendExecuteRequest, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.SendExecuteRequest);
				}
			}
		}

		private static void ValidateTransactionContext(OracleConnectionImpl commImpl)
		{
			Transaction transaction = null;
			if (commImpl != null && null != commImpl.m_lastEnlistedTransaction)
			{
				try
				{
					transaction = Transaction.Current;
					if (null == transaction)
					{
						try
						{
							_ = commImpl.m_lastEnlistedTransaction.TransactionInformation.Status;
							transaction = commImpl.m_lastEnlistedTransaction;
						}
						catch
						{
							commImpl.m_lastEnlistedTransaction = null;
							return;
						}
					}
				}
				catch
				{
					commImpl.m_lastEnlistedTransaction = null;
					return;
				}
			}
			if (null != transaction && transaction == commImpl.m_lastEnlistedTransaction && transaction.TransactionInformation.Status != 0)
			{
				throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.CON_TXN_NOT_DISPOSED));
			}
		}

		private void WriteOall8Message(byte[] sqlStmtByteStream, int cursorId, byte[] describeInfoHash, long dbChangeRegistrationId, long executeOptions, ColumnDescribeInfo[] colDefinesInfoArray, int longFetchSize, int arrayBindCount, int numDefineCols, long noOfRowsToFetch, SqlStatementType stmtType, ref MarshalBindParameterValueHelper marshalBindParamsHelper, int startIndex)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WriteOall8Message);
			}
			try
			{
				WriteFunctionHeader();
				int paramLength = 0;
				if (marshalBindParamsHelper.m_paramCollInfoArray != null)
				{
					paramLength = marshalBindParamsHelper.m_paramCollInfoArray.Length;
				}
				WritePisdef(executeOptions, cursorId, describeInfoHash, dbChangeRegistrationId, sqlStmtByteStream, paramLength, longFetchSize, numDefineCols, noOfRowsToFetch, arrayBindCount, stmtType);
				WritePisdefData(executeOptions, describeInfoHash, sqlStmtByteStream, colDefinesInfoArray, arrayBindCount, ref marshalBindParamsHelper, startIndex);
				m_marshallingEngine.m_oraBufWriter.FlushData();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WriteOall8Message, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WriteOall8Message);
				}
			}
		}

		private void WritePisdef(long executeOptions, int cursorId, byte[] describeInfoHash, long dbChangeRegistrationId, byte[] sqlStmtByteStream, int paramLength, int longFetchSize, int numDefineCols, long noOfRowsToFetch, int arrayBindCount, SqlStatementType stmtType)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WritePisdef);
			}
			try
			{
				m_marshallingEngine.MarshalUB4(executeOptions);
				m_marshallingEngine.MarshalSWORD(cursorId);
				int value = 0;
				if (cursorId > 0)
				{
					m_marshallingEngine.MarshalNullPointer();
				}
				else
				{
					m_marshallingEngine.MarshalPointer();
					if (sqlStmtByteStream != null)
					{
						value = sqlStmtByteStream.Length;
					}
				}
				m_marshallingEngine.MarshalSWORD(value);
				m_marshallingEngine.MarshalPointer();
				m_marshallingEngine.MarshalSWORD(m_al8i4.Length);
				m_marshallingEngine.MarshalNullPointer();
				m_marshallingEngine.MarshalNullPointer();
				if ((executeOptions & 0x40) == 0L && (executeOptions & 0x20) != 0L && (executeOptions & 1) != 0L && stmtType == SqlStatementType.SELECT)
				{
					m_marshallingEngine.MarshalUB4(0L);
					m_marshallingEngine.MarshalUB4(noOfRowsToFetch);
				}
				else
				{
					m_marshallingEngine.MarshalUB4(0L);
					m_marshallingEngine.MarshalUB4(0L);
				}
				switch (longFetchSize)
				{
				case -1:
					m_marshallingEngine.MarshalUB4(2147483647L);
					break;
				case 0:
					m_marshallingEngine.MarshalUB4(1L);
					break;
				default:
					m_marshallingEngine.MarshalUB4(longFetchSize);
					break;
				}
				if ((executeOptions & 8) != 0L && paramLength > 0)
				{
					m_marshallingEngine.MarshalPointer();
                    m_marshallingEngine.MarshalSWORD(paramLength); //31
                }
				else
				{
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalSWORD(0);
				}
				m_marshallingEngine.MarshalNullPointer();
				m_marshallingEngine.MarshalNullPointer();
				m_marshallingEngine.MarshalNullPointer();
				m_marshallingEngine.MarshalNullPointer();
				m_marshallingEngine.MarshalNullPointer();
				if ((executeOptions & 0x10) != 0L && numDefineCols > 0)
				{
					m_marshallingEngine.MarshalPointer();
					m_marshallingEngine.MarshalSWORD(numDefineCols);
				}
				else
				{
					m_marshallingEngine.MarshalNullPointer();
                    m_marshallingEngine.MarshalSWORD(0);
                }//40
                if (m_marshallingEngine.NegotiatedTTCVersion < 4)
				{
					return;
				}
				int num = 0;
				int num2 = 0;
				num = (int)(dbChangeRegistrationId & 0xFFFFFFFFu);
				num2 = (int)((ulong)(dbChangeRegistrationId & -4294967296L) >> 32);
				m_marshallingEngine.MarshalUB4(num);
				m_marshallingEngine.MarshalNullPointer();
				m_marshallingEngine.MarshalPointer();
				if (m_marshallingEngine.NegotiatedTTCVersion < 5)
				{
					return;
				}
                m_marshallingEngine.MarshalNullPointer();//43
                m_marshallingEngine.MarshalUB4(0L);
				if (describeInfoHash != null)
				{
					m_marshallingEngine.MarshalPointer();
					m_marshallingEngine.MarshalUB4(describeInfoHash.Length);
				}
				else
				{
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalUB4(0L);
                }//47
                m_marshallingEngine.MarshalUB4(num2);
				if (m_marshallingEngine.NegotiatedTTCVersion < 7)
				{
					return;
				}
				if (SqlStatementType.DML == stmtType && arrayBindCount > 0)
				{
					m_marshallingEngine.MarshalPointer();
					m_marshallingEngine.MarshalUB4(arrayBindCount);
					m_marshallingEngine.MarshalPointer();
				}
				else
				{
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalUB4(0L);
					m_marshallingEngine.MarshalNullPointer();
                }//51
                if (m_marshallingEngine.NegotiatedTTCVersion >= 8)
				{
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalUB4(0L);
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalUB4(0L);
                    m_marshallingEngine.MarshalNullPointer();
                    if (m_marshallingEngine.NegotiatedTTCVersion >= 9) //56
                    {
						m_marshallingEngine.MarshalNullPointer();
						m_marshallingEngine.MarshalUB4(0L);
                    }//58
                }
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WritePisdef, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WritePisdef);
				}
			}
		}

		internal void WritePisdefData(long executeOptions, byte[] describeInfoHash, byte[] sqlStmtByteStream, ColumnDescribeInfo[] colDefinesInfoArray, int arrayBindCount, ref MarshalBindParameterValueHelper marshalBindParamsHelper, int startIndex)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WritePisdefData);
			}
			try
			{
				if (sqlStmtByteStream != null)
				{
					m_marshallingEngine.MarshalCHR(sqlStmtByteStream);
                }//101 37 83-49
                m_marshallingEngine.MarshalUB4Array(m_al8i4);
				ColumnDescribeInfo[] paramCollInfoArray = marshalBindParamsHelper.m_paramCollInfoArray;
				if (paramCollInfoArray != null)
				{
					int num = paramCollInfoArray.Length;
					if ((executeOptions & 8) != 0L && num > 0)
					{
						MarshalBindMetaData(m_marshallingEngine, paramCollInfoArray);
					}
					if ((executeOptions & 0x10) != 0L)
					{
						MarshalDefines(m_marshallingEngine, colDefinesInfoArray);
					}
					if ((executeOptions & 0x20) != 0L && num > 0)
					{
						if (arrayBindCount > 0)
						{
							MarshalValuesForArrayBind(m_marshallingEngine, arrayBindCount, startIndex, ref marshalBindParamsHelper);
						}
						else
						{
							MarshalBindValues(m_marshallingEngine, ref marshalBindParamsHelper);
						}
					}
				}
				else if ((executeOptions & 0x10) != 0L)
				{
					MarshalDefines(m_marshallingEngine, colDefinesInfoArray);
				}
				if (describeInfoHash != null)
				{
					m_marshallingEngine.MarshalBytes(describeInfoHash, 0, describeInfoHash.Length);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WritePisdefData, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.WritePisdefData);
				}
			}
		}

		internal static void MarshalValuesForArrayBind(MarshallingEngine mEngine, int arrayBindCount, int startIndex, ref MarshalBindParameterValueHelper marshalArrayBindValuesHelper)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalValuesForArrayBind);
			}
			marshalArrayBindValuesHelper.m_IsInArrayBindingMode = true;
			try
			{
				if (marshalArrayBindValuesHelper.m_sqlStmtType != SqlStatementType.PLSQL || !marshalArrayBindValuesHelper.m_bAllOutBinds)
				{
					marshalArrayBindValuesHelper.MarshalArrayBindValues(mEngine, startIndex, arrayBindCount);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalValuesForArrayBind, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalValuesForArrayBind);
				}
			}
		}

		private static void MarshalDefines(MarshallingEngine mEngine, ColumnDescribeInfo[] definesArray)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalDefines);
			}
			try
			{
				MarshalBindMetaData(mEngine, definesArray);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalDefines, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalDefines);
				}
			}
		}

		private static void MarshalBindMetaData(MarshallingEngine mEngine, ColumnDescribeInfo[] paramCollInfoArray)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalBindMetaData);
			}
			try
			{
				int num = paramCollInfoArray.Length;
				for (int i = 0; i < num; i++)
				{
					TTCColumnMetaData.WriteMessage(mEngine, paramCollInfoArray[i]);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalBindMetaData, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalBindMetaData);
				}
			}
		}

		internal static void MarshalBindValues(MarshallingEngine mEngine, ref MarshalBindParameterValueHelper marshalBindValuesHelper)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalBindValues);
			}
			marshalBindValuesHelper.m_IsInArrayBindingMode = false;
			try
			{
				if (!marshalBindValuesHelper.m_bAllOutBinds)
				{
					marshalBindValuesHelper.MarshalBindValues(mEngine);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalBindValues, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalBindValues);
				}
			}
		}

		internal static void MarshalParameterValue(MarshallingEngine mEngine, object paramValue, byte[] qLocatorData, OraType dataType)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalParameterValue);
			}
			try
			{
				if (paramValue != null)
				{
					byte[] array = (byte[])paramValue;
					switch (dataType)
					{
					case OraType.ORA_NUMBER:
					case OraType.ORA_VARNUM:
						if (array.Length >= 22)
						{
							mEngine.MarshalCLR(array, 1, array[0]);
						}
						else
						{
							mEngine.MarshalCLR(array, 0, array.Length);
						}
						break;
					case OraType.ORA_REFCURSOR:
					case OraType.ORA_RESULTSET:
					{
						int value = BitConverter.ToInt32(array, 0);
						int noOfBytesToBeWritten = mEngine.GetNoOfBytesToBeWritten(value, 2);
						mEngine.MarshalUB4(noOfBytesToBeWritten);
						mEngine.MarshalCLR(array, noOfBytesToBeWritten);
						break;
					}
					case OraType.ORA_OCICLobLocator:
					case OraType.ORA_OCIBLobLocator:
					case OraType.ORA_OCIBFileLocator:
					{
						int num2 = array.Length;
						mEngine.MarshalUB4(num2);
						mEngine.MarshalCLR(array, 0, num2);
						if (qLocatorData != null)
						{
							mEngine.MarshalCLR(qLocatorData, 0, qLocatorData.Length);
						}
						break;
					}
					case OraType.ORA_OCIJSON:
					{
						int num = array.Length;
						byte[] array2 = TTCLob.CreateQuasiLocator(num);
						mEngine.MarshalUB4(array2.Length);
						mEngine.MarshalCLR(array2, array2.Length);
						mEngine.MarshalCLR(array, 0, num);
						break;
					}
					case OraType.ORA_CHARN:
					case OraType.ORA_LONG:
					case OraType.ORA_RAW:
					case OraType.ORA_LONGRAW:
					case OraType.ORA_CHAR:
						mEngine.MarshalCLR(array, array.Length);
						break;
					case OraType.ORA_INTY:
						mEngine.MarshalDALC(null);
						mEngine.MarshalDALC(null);
						mEngine.MarshalDALC(null);
						mEngine.MarshalUB2(0);
						mEngine.MarshalUB4(array.Length);
						mEngine.MarshalUB2(1);
						mEngine.MarshalCLR(array, array.Length);
						break;
					default:
						mEngine.MarshalCLR(array, 0, array.Length);
						break;
					}
					array = null;
				}
				else
				{
					switch (dataType)
					{
					case OraType.ORA_OCICLobLocator:
					case OraType.ORA_OCIBLobLocator:
					case OraType.ORA_OCIBFileLocator:
					case OraType.ORA_OCIJSON:
						mEngine.MarshalUB4(0L);
						break;
					case OraType.ORA_REFCURSOR:
						mEngine.MarshalUB1(1);
						mEngine.MarshalUB1(0);
						break;
					case OraType.ORA_INTY:
						mEngine.MarshalDALC(null);
						mEngine.MarshalDALC(null);
						mEngine.MarshalDALC(null);
						mEngine.MarshalUB2(0);
						mEngine.MarshalUB4(0L);
						mEngine.MarshalUB2(1);
						break;
					case OraType.ORA_BOOLEAN:
						mEngine.MarshalUB1(253);
						mEngine.MarshalUB1(1);
						break;
					default:
						mEngine.MarshalUB1(0);
						break;
					case OraType.ORA_LONG:
					case OraType.ORA_LONGRAW:
						break;
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalParameterValue, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalParameterValue);
				}
			}
		}

		internal static void MarshalAssociativeArrayParameterValue(MarshallingEngine mEngine, object paramValue, OraType dataType)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalAssociativeArrayParameterValue);
			}
			try
			{
				if (paramValue != null)
				{
					int length = (paramValue as Array).Length;
					mEngine.MarshalUB4(length);
					for (int i = 0; i < length; i++)
					{
						byte[] array = ((byte[][])paramValue)[i];
						if (array == null)
						{
							mEngine.MarshalUB4(0L);
							continue;
						}
						switch (dataType)
						{
						case OraType.ORA_NUMBER:
						case OraType.ORA_VARNUM:
							if (array.Length >= 22)
							{
								mEngine.MarshalCLR(array, 1, array[0]);
							}
							else
							{
								mEngine.MarshalCLR(array, 0, array.Length);
							}
							break;
						default:
							mEngine.MarshalCLR(array, array.Length);
							break;
						case OraType.ORA_OCICLobLocator:
						case OraType.ORA_OCIBLobLocator:
							break;
						}
						array = null;
					}
				}
				else
				{
					mEngine.MarshalUB4(0L);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalAssociativeArrayParameterValue, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.MarshalAssociativeArrayParameterValue);
				}
			}
		}

		internal List<TTCResultSet> ProcessImplicitResultSet(ref List<TTCResultSet> implicitRSList)
		{
			int num = (int)m_marshallingEngine.UnmarshalUB4();
			TTCRefCursorAccessor tTCRefCursorAccessor = new TTCRefCursorAccessor(null, m_marshallingEngine);
			for (int i = 0; i < num; i++)
			{
				tTCRefCursorAccessor.UnmarshalOneRow();
			}
			if (implicitRSList != null)
			{
				implicitRSList.AddRange(tTCRefCursorAccessor.m_TTCResultSetList);
			}
			else
			{
				implicitRSList = tTCRefCursorAccessor.m_TTCResultSetList;
			}
			return implicitRSList;
		}

		internal void ReceiveExecuteResponse(ref Accessor[] defineAccessors, Accessor[] bindAccessors, bool bHasReturningParams, ref SQLMetaData sqlMetaData, SqlStatementType statementType, long noOfRowsFetchedLastTime, int noOfRowsToFetch, out int noOfRowsFetched, ref long queryId, int longFetchSize, long clientInitialLOBFetchSize, long initialLOBFetchSize, long initialJSONFetchSize, long[] scnFromExecution, bool bAllInputBinds, int arrayBindCount, ref DataUnmarshaller dataUnmarshaller, ref MarshalBindParameterValueHelper marshalBindParamsHelper, out long[] rowsAffectedByArrayBind, bool bDefineDone, ref bool bMoreThanOneRowAffectedByDmlWithRetClause, ref List<TTCResultSet> implicitRSList, bool bLOBArrayFetchRequired = false)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.ReceiveExecuteResponse);
			}
			noOfRowsFetched = 0;
			rowsAffectedByArrayBind = null;
			bool flag = false;
			Exception ex = null;
			try
			{
				int num = 0;
				bool bIgnoreMetadata = sqlMetaData != null && sqlMetaData.bGotDescribeInfoFromDB;
				if (m_rowData != null)
				{
					m_rowData.ReInitialize();
				}
				if (m_rowHeader != null)
				{
					m_rowHeader.ReInitialize();
				}
				bool flag2 = false;
				m_marshallingEngine.TTCErrorObject.Initialize();
				while (!flag)
				{
					try
					{
						switch ((byte)m_marshallingEngine.UnmarshalUB1())
						{
						case 23:
							ProcessServerSidePiggybackFunction(0);
							break;
						case 27:
							ProcessImplicitResultSet(ref implicitRSList);
							break;
						case 21:
						{
							int nbOfColumnSent = m_marshallingEngine.UnmarshalUB2();
							if (m_rowData == null)
							{
								m_rowData = new TTCRowData(m_marshallingEngine);
							}
							m_rowData.ReadBVC(nbOfColumnSent);
							if (noOfRowsFetched != 0 || dataUnmarshaller == null)
							{
								break;
							}
							if (m_rowData.m_bitVectorFound)
							{
								dataUnmarshaller.SaveAllDuplicateColumnsFromLastRow(m_rowData, defineAccessors, (int)noOfRowsFetchedLastTime);
							}
							else if (dataUnmarshaller.m_duplicateDataStore != null)
							{
								for (int n = 0; n < dataUnmarshaller.m_duplicateDataStore.Length; n++)
								{
									dataUnmarshaller.m_duplicateDataStore[n] = null;
								}
							}
							break;
						}
						case 11:
						{
							if (m_rowHeader == null)
							{
								m_rowHeader = new TTCRowHeader(m_marshallingEngine);
							}
							if (m_rowData == null)
							{
								m_rowData = new TTCRowData(m_marshallingEngine);
							}
							m_rowHeader.ReadMessage(m_rowData);
							num = m_rowHeader.m_noOfRequests;
							if (num <= 0)
							{
								break;
							}
							byte b = 0;
							for (int num5 = 0; num5 < num; num5++)
							{
								if ((b = (byte)m_marshallingEngine.UnmarshalUB1()) != 0)
								{
									if (32 == b)
									{
										bindAccessors[num5] = null;
									}
									if (marshalBindParamsHelper.m_bindDirections == null)
									{
										marshalBindParamsHelper.m_bindDirections = new BindDirection[num];
									}
									marshalBindParamsHelper.m_bindDirections[num5] = (BindDirection)b;
								}
							}
							marshalBindParamsHelper.EvaluateBindDirections();
							bAllInputBinds = marshalBindParamsHelper.m_bAllInBinds;
							break;
						}
						case 6:
							if (m_rowHeader == null)
							{
								m_rowHeader = new TTCRowHeader(m_marshallingEngine);
							}
							if (m_rowData == null)
							{
								m_rowData = new TTCRowData(m_marshallingEngine);
							}
							if (sqlMetaData != null)
							{
								m_rowData.SetNumberOfColumns(sqlMetaData.m_noOfColumns);
							}
							m_rowHeader.ReadMessage(m_rowData);
							if (flag2)
							{
								break;
							}
							if (statementType == SqlStatementType.SELECT)
							{
								if (noOfRowsFetched == 0 && dataUnmarshaller != null)
								{
									if (m_rowData.m_bitVectorFound)
									{
										dataUnmarshaller.SaveAllDuplicateColumnsFromLastRow(m_rowData, defineAccessors, (int)noOfRowsFetchedLastTime);
									}
									else if (dataUnmarshaller.m_duplicateDataStore != null)
									{
										if (dataUnmarshaller.m_duplicateDataStore.Length != sqlMetaData.m_noOfColumns)
										{
											dataUnmarshaller.m_duplicateDataStore = null;
										}
										else
										{
											for (int i = 0; i < dataUnmarshaller.m_duplicateDataStore.Length; i++)
											{
												dataUnmarshaller.m_duplicateDataStore[i] = null;
											}
										}
									}
								}
								int num2 = sqlMetaData.m_noOfColumns * noOfRowsToFetch;
								if (dataUnmarshaller == null)
								{
									dataUnmarshaller = new DataUnmarshaller(m_marshallingEngine);
									m_marshallingEngine.m_oraBufRdr.m_colDataStartOffset = new int[num2];
									m_marshallingEngine.m_oraBufRdr.m_indexOfOASArray = new int[num2];
									m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfo = new OraArraySegment[noOfRowsToFetch];
								}
								else
								{
									DataUnmarshaller.ReleaseAllOBs(dataUnmarshaller.m_oraArrSegWithColRowInfo, dataUnmarshaller.m_oraArrSegCount, m_marshallingEngine.m_oracleCommunication);
									if (dataUnmarshaller.m_colDataStartOffset == null || dataUnmarshaller.m_colDataStartOffset.Length < num2)
									{
										m_marshallingEngine.m_oraBufRdr.m_colDataStartOffset = new int[num2];
										m_marshallingEngine.m_oraBufRdr.m_indexOfOASArray = new int[num2];
									}
									else
									{
										m_marshallingEngine.m_oraBufRdr.m_colDataStartOffset = dataUnmarshaller.m_colDataStartOffset;
										m_marshallingEngine.m_oraBufRdr.m_indexOfOASArray = dataUnmarshaller.m_indexOfOASArray;
									}
									if (dataUnmarshaller.m_oraArrSegWithColRowInfo == null || dataUnmarshaller.m_oraArrSegWithColRowInfo.Length < noOfRowsToFetch)
									{
										m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfo = new OraArraySegment[noOfRowsToFetch];
									}
									else
									{
										m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfo = dataUnmarshaller.m_oraArrSegWithColRowInfo;
									}
								}
								m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfoIndex = 0;
								if (clientInitialLOBFetchSize < 0 || (clientInitialLOBFetchSize < initialLOBFetchSize && initialLOBFetchSize == 32768))
								{
									clientInitialLOBFetchSize = 32768L;
								}
								if (defineAccessors == null)
								{
									defineAccessors = CreateDefineAccessors(sqlMetaData, longFetchSize, clientInitialLOBFetchSize, initialLOBFetchSize, initialJSONFetchSize, bDefineDone, bLOBArrayFetchRequired, noOfRowsToFetch);
									break;
								}
								Accessor[] array = defineAccessors;
								foreach (Accessor accessor in array)
								{
									if (accessor == null)
									{
										continue;
									}
									accessor.m_lastRowProcessed = 0;
									if (accessor is TTCLongAccessor && accessor.m_totalLengthOfData != null)
									{
										accessor.m_totalLengthOfData.Clear();
									}
									else if (accessor.GetType() == typeof(TTCJsonAccessor))
									{
										((TTCJsonAccessor)accessor).ReInit(bLOBArrayFetchRequired, initialJSONFetchSize, noOfRowsToFetch);
										((TTCJsonAccessor)accessor).m_isDefineDone = bDefineDone;
									}
									else if (accessor is TTCLobAccessor)
									{
										if (accessor.m_colMetaData.m_bIsValueLob)
										{
											((TTCLobAccessor)accessor).ReInit(bLOBArrayFetchRequired, clientInitialLOBFetchSize, noOfRowsToFetch);
										}
										else
										{
											((TTCLobAccessor)accessor).ReInit(bLOBArrayFetchRequired, initialLOBFetchSize, noOfRowsToFetch);
										}
										((TTCLobAccessor)accessor).m_isDefineDone = bDefineDone;
									}
								}
							}
							else if (defineAccessors == null)
							{
								defineAccessors = new Accessor[sqlMetaData.m_noOfColumns];
							}
							break;
						case 7:
							flag2 = true;
							if (bHasReturningParams && bindAccessors != null)
							{
								int num3 = bindAccessors.Length;
								m_marshallingEngine.m_oraBufRdr.m_bHoldOBTemporarily = true;
								for (int k = 0; k < num3; k++)
								{
									if (bindAccessors[k] == null)
									{
										continue;
									}
									int num4 = (int)m_marshallingEngine.UnmarshalUB4();
									if (num4 > 1)
									{
										bMoreThanOneRowAffectedByDmlWithRetClause = true;
									}
									if (num4 == 0)
									{
										bindAccessors[k].AddNullForData();
										continue;
									}
									for (int l = 0; l < num4; l++)
									{
										bindAccessors[k].m_bReceivedOutValueFromServer = true;
										bindAccessors[k].UnmarshalOneRow();
									}
								}
								if (m_marshallingEngine.m_oraBufRdr.m_currentOB != null)
								{
									m_marshallingEngine.m_oraBufRdr.m_tempOBList.Add(m_marshallingEngine.m_oraBufRdr.m_currentOB);
									m_marshallingEngine.m_oraBufRdr.m_currentOB = null;
								}
								m_marshallingEngine.m_oraBufRdr.m_bHoldOBTemporarily = false;
								noOfRowsFetched++;
								break;
							}
							if (m_rowData == null)
							{
								m_rowData = new TTCRowData(m_marshallingEngine);
							}
							if (bindAccessors != null && !bAllInputBinds)
							{
								if (noOfRowsFetched == 0)
								{
									m_marshallingEngine.m_oraBufRdr.StartAccumulatingRowData();
								}
								m_marshallingEngine.m_oraBufRdr.m_bHoldOBTemporarily = true;
								m_rowData.ReadRow(bindAccessors, bindAccessors.Length);
								if (m_marshallingEngine.m_oraBufRdr.m_currentOB != null)
								{
									m_marshallingEngine.m_oraBufRdr.m_tempOBList.Add(m_marshallingEngine.m_oraBufRdr.m_currentOB);
									m_marshallingEngine.m_oraBufRdr.m_currentOB = null;
								}
								m_marshallingEngine.m_oraBufRdr.m_bHoldOBTemporarily = false;
								for (int m = 0; m < num; m++)
								{
									TTCRefCursorAccessor tTCRefCursorAccessor = bindAccessors[m] as TTCRefCursorAccessor;
									if (tTCRefCursorAccessor != null)
									{
										if (clientInitialLOBFetchSize < 0 || (clientInitialLOBFetchSize < initialLOBFetchSize && initialLOBFetchSize == 32768))
										{
											clientInitialLOBFetchSize = 32768L;
										}
										Accessor[] array3 = (tTCRefCursorAccessor.DefineAccessorForCurrentRow = CreateDefineAccessors(tTCRefCursorAccessor.SqlMetaDataForCurrentRow, longFetchSize, clientInitialLOBFetchSize, initialLOBFetchSize, initialJSONFetchSize, bDefineDone));
									}
								}
							}
							else
							{
								m_rowData.ReadRowNew(dataUnmarshaller, defineAccessors, noOfRowsFetched);
								m_marshallingEngine.m_oraBufRdr.UpdateOASMaxRow(noOfRowsFetched);
							}
							noOfRowsFetched++;
							break;
						case 8:
							Process_RPA_Message(ref queryId, scnFromExecution, statementType, arrayBindCount, out rowsAffectedByArrayBind);
							break;
						case 19:
							m_marshallingEngine.MarshalUB1(19);
							m_marshallingEngine.m_oraBufWriter.FlushData();
							break;
						case 16:
							if (sqlMetaData == null)
							{
								sqlMetaData = new SQLMetaData();
							}
							TTCDescribeInfo.ReadMessage(bForDescribe: false, bForRefCursor: false, m_marshallingEngine, sqlMetaData, bIgnoreMetadata);
							if (m_rowData == null)
							{
								m_rowData = new TTCRowData(m_marshallingEngine);
							}
							break;
						case 15:
							m_marshallingEngine.TTCErrorObject.ReadWarning();
							break;
						case 4:
							m_marshallingEngine.TTCErrorObject.ReadErrorMessage();
							flag = true;
							break;
						case 12:
							if (m_rowData == null)
							{
								m_rowData = new TTCRowData(m_marshallingEngine);
							}
							else
							{
								m_rowData.ReInitialize();
							}
							if (m_rowHeader == null)
							{
								m_rowHeader = new TTCRowHeader(m_marshallingEngine);
							}
							else
							{
								m_rowHeader.ReInitialize();
							}
							m_rowHeader.ReadMessage(m_rowData);
							if (!marshalBindParamsHelper.Equals(MarshalBindParameterValueHelper.Null))
							{
								marshalBindParamsHelper.m_InTTISLGMode = true;
								marshalBindParamsHelper.MarshalBindParameters(m_marshallingEngine, m_rowHeader.m_iterationNumber, m_rowHeader.m_noOfIterations);
								marshalBindParamsHelper.m_InTTISLGMode = false;
							}
							break;
						case 28:
							m_marshallingEngine.m_connImplReference.DoProtocolNegotiation();
							m_marshallingEngine.m_connImplReference.DoDataTypeNegotiation();
							break;
						default:
							throw new Exception("TTCExecuteSql:ReceiveExecuteResponse - Unexpected Packet received.");
						}
					}
					catch (NetworkException ex2)
					{
						if (ex2.ErrorCode != 3111)
						{
							throw;
						}
						m_marshallingEngine.m_oracleCommunication.Reset();
					}
					catch (Exception ex3)
					{
						ex = ex3;
						if (m_marshallingEngine.m_oraBufRdr != null)
						{
							m_marshallingEngine.m_oraBufRdr.ClearState();
						}
						m_marshallingEngine.m_oracleCommunication.Break();
						m_marshallingEngine.m_oracleCommunication.Reset();
					}
				}
				if (ex != null)
				{
					throw ex;
				}
				if (statementType == SqlStatementType.SELECT && dataUnmarshaller != null)
				{
					dataUnmarshaller.m_columnCount = sqlMetaData.m_noOfColumns;
					dataUnmarshaller.m_colDataStartOffset = m_marshallingEngine.m_oraBufRdr.m_colDataStartOffset;
					dataUnmarshaller.m_indexOfOASArray = m_marshallingEngine.m_oraBufRdr.m_indexOfOASArray;
					dataUnmarshaller.m_oraArrSegWithColRowInfo = m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfo;
					dataUnmarshaller.m_oraArrSegCount = m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfoIndex;
					dataUnmarshaller.m_bFirstNonNullOraArrSegWithColInfoEntry = 0;
					dataUnmarshaller.m_indexOfLastOraArrSegUsed = 0;
					m_marshallingEngine.m_oraBufRdr.m_colDataStartOffset = null;
					m_marshallingEngine.m_oraBufRdr.m_indexOfOASArray = null;
					m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfo = null;
					m_marshallingEngine.m_oraBufRdr.m_oraArrSegWithColRowInfoIndex = 0;
				}
			}
			catch (Exception ex4)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.ReceiveExecuteResponse, ex4);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.ReceiveExecuteResponse);
				}
			}
		}

		private void Process_RPA_Message(ref long queryId, long[] scnFromExecution, SqlStatementType statementType, int arrayBindCount, out long[] rowsAffectedByArrayBind)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.Process_RPA_Message);
			}
			rowsAffectedByArrayBind = null;
			try
			{
				int num = m_marshallingEngine.UnmarshalUB2();
				int num2 = 0;
				if (scnFromExecution != null)
				{
					int num3 = 32768;
					scnFromExecution[0] = (int)m_marshallingEngine.UnmarshalUB4();
					scnFromExecution[1] = (int)m_marshallingEngine.UnmarshalUB4() & ~num3;
					num2 += 2;
				}
				for (int i = num2; i < num; i++)
				{
					m_marshallingEngine.UnmarshalUB4(bIgnoreData: true);
				}
				int num4 = m_marshallingEngine.UnmarshalUB2();
				if (num4 > 0)
				{
					num4 = m_marshallingEngine.UnmarshalNBytes_ScanOnly(num4);
				}
				int num5 = m_marshallingEngine.UnmarshalUB2();
				TTCKeywordValuePair[] array = new TTCKeywordValuePair[num5];
				StringBuilder stringBuilder = new StringBuilder();
				for (int j = 0; j < num5; j++)
				{
					array[j] = TTCKeywordValuePair.Unmarshal(m_marshallingEngine);
					if (ProviderConfig.m_bTraceLevelPrivate)
					{
						if (array[j].m_keyword >= 0)
						{
							stringBuilder.Append("[" + array[j].m_keyword + "]" + m_marshallingEngine.m_connImplReference.GetCorrespondingAuthAttrName(array[j].m_keyword) + " ==> ");
						}
						if (array[j].m_binaryValue != null)
						{
							stringBuilder.Append(m_marshallingEngine.m_dbCharSetConv.ConvertBytesToString(array[j].m_binaryValue, 0, array[j].m_binaryValue.Length));
						}
					}
				}
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.TTIRPA, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.Process_RPA_Message, stringBuilder.ToString());
				}
				m_marshallingEngine.m_connImplReference.UpdateSessionAttributes(array, null);
				if (m_marshallingEngine.NegotiatedTTCVersion < 4)
				{
					return;
				}
				int num6 = (int)m_marshallingEngine.UnmarshalUB4();
				if (num6 > 0)
				{
					byte[] array2 = m_marshallingEngine.UnmarshalNBytes(num6);
					bool flag = true;
					int byteCount = num6;
					if (flag)
					{
						byteCount = num6 - 8;
					}
					char[] t = m_marshallingEngine.m_charArrayPooler.Dequeue();
					string text = Conv.GetInstance(871).ConvertBytesToString(array2, 0, byteCount, t);
					m_marshallingEngine.m_charArrayPooler.Enqueue(ref t);
					char[] separator = new char[1];
					text.Split(separator);
					if (flag)
					{
						int num7 = array2[num6 - 1] | (array2[num6 - 2] << 8) | (array2[num6 - 3] << 16) | (array2[num6 - 4] << 24);
						int num8 = array2[num6 - 5] | (array2[num6 - 6] << 8) | (array2[num6 - 7] << 16) | (array2[num6 - 8] << 24);
						queryId = (num8 & 0xFFFFFFFFu) | ((long)num7 << 32);
					}
				}
				if (m_marshallingEngine.NegotiatedTTCVersion < 7 || SqlStatementType.DML != statementType || arrayBindCount <= 0)
				{
					return;
				}
				int num9 = (int)m_marshallingEngine.UnmarshalUB4();
				if (num9 > 0)
				{
					rowsAffectedByArrayBind = new long[num9];
					for (int k = 0; k < num9; k++)
					{
						rowsAffectedByArrayBind[k] = m_marshallingEngine.UnmarshalSB8();
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.Process_RPA_Message, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.Process_RPA_Message);
				}
			}
		}

		private long GetExecuteOptions(bool parse, bool execute, bool fetch, bool bDoDefines, bool bAutoCommit, bool bDisableCompressedFetch, bool bHasReturningClause, int noOfParameters, int arrayBindCount, SqlStatementType stmtType)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.GetExecuteOptions);
			}
			long num = 0L;
			if (bDisableCompressedFetch)
			{
				num = 262144L;
			}
			try
			{
				if (stmtType != SqlStatementType.SELECT && bAutoCommit)
				{
					num |= 0x100;
				}
				if (arrayBindCount > 1 && SqlStatementType.DML == stmtType)
				{
					num |= 0x80000;
				}
				if (parse && !execute && !fetch)
				{
					num |= 0x28001;
				}
				else if (parse && execute && !fetch)
				{
					num |= 0x8021;
				}
				else if (execute && fetch)
				{
					if (parse)
					{
						num |= 1;
					}
					switch (stmtType)
					{
					case SqlStatementType.SELECT:
						num |= 0x8060;
						break;
					case SqlStatementType.DML:
					case SqlStatementType.OTHERS:
						num = ((!bHasReturningClause) ? (num | 0x8020) : ((!parse) ? (num | 0x20) : (num | 0x420)));
						break;
					case SqlStatementType.PLSQL:
						num = ((noOfParameters <= 0) ? (num | 0x20) : ((!parse) ? (num | 0x20) : (num | 0x420)));
						break;
					}
				}
				else if (!parse && !execute && fetch)
				{
					num |= 0x8040;
				}
				else
				{
					if (!(!parse && execute) || fetch)
					{
						throw new Exception("Invalid Execution Options");
					}
					num |= 0x8020;
				}
				if (noOfParameters > 0)
				{
					num |= 8;
				}
				if (bDoDefines)
				{
					num |= 0x10;
				}
				return num &= 0xFFFFFFFFu;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.GetExecuteOptions, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.GetExecuteOptions);
				}
			}
		}

		private Accessor[] CreateDefineAccessors(SQLMetaData sqlMetaData, int initialLongFetchSize, long clientInitialLobFetchsize, long initialLOBFetchSize, long initialJSONFetchSize, bool bDefineDone, bool bLOBArrayFetchRequired = false, int noOfRowsToFetch = 0)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.CreateDefineAccessors);
			}
			try
			{
				Accessor[] array = new Accessor[sqlMetaData.m_noOfColumns];
				for (int i = 0; i < array.Length; i++)
				{
					if (sqlMetaData != null && array[i] == null)
					{
						ColumnDescribeInfo columnDescribeInfo = sqlMetaData.m_columnDescribeInfo[i];
						if (columnDescribeInfo.m_bIsValueLob)
						{
							initialLOBFetchSize = clientInitialLobFetchsize;
						}
						array[i] = Accessor.CreateAccessorForDefine(m_marshallingEngine, columnDescribeInfo, initialLongFetchSize, initialLOBFetchSize, initialJSONFetchSize, bDefineDone, bLOBArrayFetchRequired, noOfRowsToFetch);
					}
				}
				return array;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.CreateDefineAccessors, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.CreateDefineAccessors);
				}
			}
		}

		internal static ColumnDescribeInfo[] InitDefines(ColumnDescribeInfo[] columnMetadataArray, long clientInitialLOBFetchSize, long initialLOBFetchSize, long initialJSONFetchsize)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.InitDefines);
			}
			try
			{
				if (columnMetadataArray == null)
				{
					return null;
				}
				int maxLength = int.MaxValue;
				ColumnDescribeInfo[] array = new ColumnDescribeInfo[columnMetadataArray.Length];
				for (int i = 0; i < columnMetadataArray.Length; i++)
				{
					array[i] = new ColumnDescribeInfo();
					array[i].m_dataType = columnMetadataArray[i].m_dataType;
					if (columnMetadataArray[i].m_dataType == 113 || columnMetadataArray[i].m_dataType == 112)
					{
						maxLength = 0;
						array[i].m_contFlag |= 33554432L;
						if (initialLOBFetchSize == -1)
						{
							maxLength = int.MaxValue;
							array[i].m_maxLengthOfChars = 0;
							if (columnMetadataArray[i].m_dataType == 112)
							{
								array[i].m_dataType = 1;
							}
							else
							{
								array[i].m_dataType = 23;
							}
						}
						else if (columnMetadataArray[i].m_bIsValueLob)
						{
							if (clientInitialLOBFetchSize < 0 || (clientInitialLOBFetchSize < initialLOBFetchSize && initialLOBFetchSize == 32768))
							{
								array[i].m_maxLengthOfChars = 32768;
							}
							else
							{
								array[i].m_maxLengthOfChars = (int)clientInitialLOBFetchSize;
							}
						}
						else
						{
							array[i].m_maxLengthOfChars = (int)initialLOBFetchSize;
						}
					}
					else if (columnMetadataArray[i].m_dataType == 119)
					{
						maxLength = 0;
						array[i].m_contFlag |= 33554432L;
						array[i].m_maxLengthOfChars = (int)initialJSONFetchsize;
					}
					array[i].m_flag = 3;
					if (columnMetadataArray[i].m_dataType != 119)
					{
						array[i].m_characterSetForm = columnMetadataArray[i].m_characterSetForm;
						array[i].m_characterSetId = columnMetadataArray[i].m_characterSetId;
					}
					else
					{
						array[i].m_characterSetForm = 1;
						array[i].m_characterSetId = 873;
					}
					array[i].m_maxLength = maxLength;
				}
				return array;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.InitDefines, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCExecuteSql, OracleTraceFuncName.InitDefines);
				}
			}
		}

		internal static long CalculateInternalILFS(long lobPrefetchSize, bool bForFill, bool bReturnPSTypes)
		{
			int num = 32768;
			long result = lobPrefetchSize;
			if (ConfigBaseClass.m_bLegacyNegativeOneILFSBehavior)
			{
				if (-1 == lobPrefetchSize)
				{
					result = num;
				}
				else if (lobPrefetchSize == 0L)
				{
					if (bForFill && !bReturnPSTypes)
					{
						result = num;
					}
				}
				else if (!bReturnPSTypes)
				{
					result = ((lobPrefetchSize > num) ? lobPrefetchSize : num);
				}
			}
			else if (bForFill)
			{
				result = (bReturnPSTypes ? 0 : ((lobPrefetchSize > 0) ? ((lobPrefetchSize > num) ? lobPrefetchSize : num) : num));
			}
			else if (lobPrefetchSize < 0)
			{
				result = num;
			}
			return result;
		}
	}
}
